package com.ilearn.zookeeper.distributionlock;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;

/**
 * @Project: seb-core
 * @Description:
 * @Version 1.0
 * @Throws SystemException:
 * @Author: <li>2018/12/25 lyndon Create 1.0
 * @Copyright (c)2018-2018 中央结算公司，版权所有
 * @Modified By:
 */
public class AppTestDistributedLock {
    public static void main(String[] args) throws IOException {

        final CountDownLatch countDownLatch = new CountDownLatch(10);
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                try {
                    countDownLatch.await();
                    final DistributedLock distributedLock = new DistributedLock();
                    distributedLock.lock(); //获得锁
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            },"Thread-" + i).start();
            countDownLatch.countDown();
        }
        System.in.read();
    }
}
